 
import { useI18n } from 'vue-i18n'
import type { IJsonItem } from '../types'

export function useExecutorMemory(): IJsonItem {
  const { t } = useI18n()

  return {
    type: 'input',
    field: 'executorMemory',
    name: t('project.node.executor_memory'),
    span: 12,
    props: {
      placeholder: t('project.node.executor_memory_tips')
    },
    validate: {
      trigger: ['input', 'blur'],
      required: true,
      validator(validate: any, value: string) {
        if (!value) {
          return new Error(t('project.node.executor_memory_tips'))
        }
        if (!Number.isInteger(parseInt(value))) {
          return new Error(
            t('project.node.executor_memory_tips') +
              t('project.node.positive_integer_tips')
          )
        }
      }
    }
  }
}
